Fallback to RS256 when certificate PSS signing fails#6126
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses token acquisition failures on .NET Framework when using certificates whose private keys are backed by legacy Windows CSP providers (exposed as RSACryptoServiceProvider), by falling back from PS256/PSS to RS256/PKCS#1 for client assertions while keeping x5c emission governed solely by the request option.
Changes:
- Add legacy CSP-backed certificate detection and reuse of resolved RSA providers in
CommonCryptographyManager. - Downgrade assertion signing from PS256 to RS256 when a legacy CSP-backed key is detected to avoid PSS padding failures.
- Add a .NET Framework unit test that creates a CertEnroll CSP certificate and validates the outgoing
client_assertionheader and PKCS#1 signature through the mocked HTTP pipeline.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/Microsoft.Identity.Test.Unit/PublicApiTests/ClientCredentialWithCertTest.cs | Adds a net48-only test creating a legacy CSP-backed cert via CertEnroll and validating an RS256/PKCS#1 client assertion. |
| src/client/Microsoft.Identity.Client/PlatformsCommon/Shared/CommonCryptographyManager.cs | Introduces legacy CSP detection and refactors RSA provider caching into helpers reused by signing and detection. |
| src/client/Microsoft.Identity.Client/PlatformsCommon/Interfaces/ICryptographyManager.cs | Extends the internal crypto interface with legacy CSP certificate detection. |
| src/client/Microsoft.Identity.Client/Internal/JsonWebToken.cs | Switches to RS256 when legacy CSP is detected while preserving request-level sendX5C behavior. |
gladjohn
approved these changes
Jul 15, 2026
gladjohn
left a comment
Contributor
There was a problem hiding this comment.
are SHA‑256-incapable CSPs (PROV_RSA_FULL, PROV_RSA_SCHANNEL) are in or out of scope?
neha-bhargava
approved these changes
Jul 15, 2026
bgavrilMS
force-pushed
the
bgavril/legacy-csp-client-assertions
branch
from
July 15, 2026 21:12
861ca12 to
44cfa8e
Compare
neha-bhargava
approved these changes
Jul 15, 2026
gladjohn
approved these changes
Jul 15, 2026
gladjohn
approved these changes
Jul 15, 2026
This was referenced Jul 16, 2026
Closed
Closed
fix: Bump Microsoft.Identity.Client from 4.86.0 to 4.86.1
Halceyon/open-telemetry-trace-listener#239
Merged
Open
Merged
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CryptographicExceptionRS256withx5twhile reusing the original encoded payloadx5cbehavior independent from signing fallbackTest coverage
AcquireTokenForClientflow through the mocked HTTP pipelineclient_assertionRS256,x5t,x5c, and the PKCS#1 SHA-256 signatureCloses #6125